﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunityToolkit.Mvvm.ComponentModel;
using System.Threading.Tasks;
using System.Data;

namespace App2Wpf.Models
{
    public class FirstWindowModel : ObservableObject
    {

        public List<string> _UiCombox = new List<string> { "127.0.0.1", "192.168.0.9", "192.168.0.10", };
        public List<string> UiCombox
        {
            get => _UiCombox;
            set => SetProperty(ref _UiCombox, value);
        }

        private List<nameip> _remotes = clientFunc.readIP();
        private List<nameip> remotes
        {
            get {
                
                //for (int i = 0; i < _remotes.Count; i++)
                //{
                //    _remotes[i].no = i + 1;
                //}
                return _remotes;
            }
            set { }
        }

        public DataTable _dt;

        public DataTable dt
        {
            get
            {
                DataTable tempDt = new DataTable();
                DataColumn[] columns = new DataColumn[]
                {
                    new DataColumn("No"),
                    new DataColumn("Name"),
                    new DataColumn("ip") 
                };
                tempDt.Columns.AddRange(columns);
                for (int i = 0; i < remotes.Count; i++)
                {
                    tempDt.Rows.Add(i+1, remotes[i].name, remotes[i].ip);
                }
                _dt = tempDt;
                return tempDt;
            }
            set => SetProperty(ref _dt, value);
        }

        public List<nameip> _iplist; 
        public List<nameip> iplist
        {
            get
            {   
                for (int i = 0; i < remotes.Count; i++)
                {
                    remotes[i].no = i + 1;
                }
                return remotes;
                
            }
            set => SetProperty(ref _iplist, value);
        }







    }
}
